#include <iostream>
#include <ctime>
#include "ThreadPool.hpp"
#include "Task.hpp"

int main()
{
  std::cout << "process runn..." << std::endl;
  sleep(3);
  // ThreadPool<Task> *tp = new ThreadPool<Task>(5);
  ThreadPool<Task>::GetInstance()->Start(); // 线程启动
  srand(time(nullptr) ^ getpid());

  while (true)
  {
    // 1.创建任务
    int x = rand() % 10 + 1;
    usleep(10);
    int y = rand() % 5;
    char op = opers[rand() % opers.size()];
    Task t(x, y, op);
    ThreadPool<Task>::GetInstance()->Push(t); // 把任务push进去
    // 2.交给线程池处理
    std::cout << "main thread make: " << t.GetTask() << std::endl;
    sleep(1);
  }
  return 0;
}
